#!/bin/sh

#These scripts are written by me. If you want to use them, feel free to. But don't take credit for them

#read default image point

read < /boot/home/config/settings/imagepoint imagepoint

#alert box, initial user input

alert --warning "                         -- WriteCD 2.0 --                                                         A) Make and burn a CD Image.                                                 B) Burn a pre-exsisting CD Image.                                                                                        C) Directly copy a CD." "[A]" "[B]" "[C]" 
 
#run the code for the option selected

ICP=$?
 if [ $ICP -eq 0 ]  #Choose a bfs or iso cd, then run the scripts to create/burn
 then
 alert --warning "Would you like to make a BFS CD or an ISO9660 CD?" "BFS" "ISO"
 BI=$?
  if [ $BI -eq 0 ] # Make a BFS image and then burn it
  then
   Terminal -t "Making BFS Image" /boot/home/config/bin/MakeBFS  #call the make image script
   sync  #sync, thanks yak
   mkdir /mnt
   mount $imagepoint/image.img /mnt #make a mount dir, and mount the image
   alert --warning "Please copy all the files you want on the CD to the mounted Image. Title the image, and then unmount         it. When that is done, cliick OK, and the burn process will begin." 
  Terminal -t "BFS CD Creation" /boot/home/config/bin/WriteBFS #call the write image script
   fi

   if [ $BI -eq 1 ] # Make an ISO9660 CD and then burn it
    then
    mkdir $imagepoint/cdromiso
    /boot/beos/system/Tracker $imagepoint/cdromiso
    alert "Please copy the files you want on the ISO CD to $imagepoint/cdromiso . After you are done, close the   directory, and click OK" 
    Terminal -t "ISO CD Creation" /boot/home/config/bin/WriteISO
   fi
fi

if [ $ICP -eq 1 ] # burn a pre-exsisting image
   then 
    Terminal -t "Preparing to write pre-exsisting image" /boot/home/config/bin/WritePRE
fi

if [ $ICP -eq 2 ] # Copy a CD to an image file, then burn the image to a cd
   then
    alert "Please insert the CD to be copied" "Ok"
    Terminal -t "CD Duplication" /boot/home/config/bin/DupCD
   fi
